package com.example.test_touch.test

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.widget.AppCompatButton

/**
 * @author ytx
 * @date 2025-09-27 09:01
 * @description
 */
class MyButton:AppCompatButton {
    companion object{
        const val TAG = "MyButton"
    }
    constructor(context: Context):this(context,null)
    constructor(context: Context, attributeSet: AttributeSet?):this(context,attributeSet,0)
    constructor(context: Context, attributeSet: AttributeSet?, defStyleAttr:Int):super(context,attributeSet,defStyleAttr)


    override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
        if (event?.action == MotionEvent.ACTION_DOWN){
            Log.d(TAG, "dispatchTouchEvent: 分发")
        }
        return super.dispatchTouchEvent(event)
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        if (event?.action == MotionEvent.ACTION_DOWN){
            Log.d(TAG, "onTouchEvent: 消费")
        }
        return super.onTouchEvent(event)
    }
}